package flexo.graphic;

public class Color
{
	public static final Color BLACK = new Color(0,0,0);
	public static final Color RED = new Color(1,0,0);
	public static final Color BLUE = new Color(0,0,1);
	public static final Color YELLOW = new Color(1,1,0);
	public static final Color GREEN = new Color(0,1,0);
	public static final Color MAGENTA = new Color(1,0,1);
	public static final Color WHITE = new Color(1,1,1);
	public static final Color GRAY = new Color(5,5,5);
	
	float red,green,blue,alpha;
	
	public Color()
	{	
		set(0.3f,0.5f,1.0f,1.0f);
	}
	
	public Color(float red, float green, float blue)
	{
		set(red,green,blue,1.0f);
	}
	
	public Color(float red, float green, float blue, float alpha)
	{
		set(red,green,blue,alpha);
	}
	
	public void set(byte red, byte green, byte blue)
	{
		this.red = red / 255.0f;
		this.green = green / 255.0f;
		this.blue = blue / 255.0f;
	}
	
	public void set(float red, float green, float blue, float alpha)
	{
		this.red = red;
		this.green = green;
		this.blue = blue;
		this.alpha = alpha;
	}
	
	public void set(float red, float green, float blue)
	{
		set(red,green,blue,this.alpha);
	}
	
	public void set(Color c)
	{
		this.red = c.red;
		this.green = c.green;
		this.blue = c.blue;
		this.alpha = c.alpha;
	}
	
	public float getRed()
	{
		return red;
	}
	
	public float getGreen()
	{
		return green;
	}
	
	public float getBlue()
	{
		return blue;
	}
	
	public float getAlpha()
	{
		return alpha;
	}
	
	public void setRed(float value)
	{
		
		red = limitValue(value);
	}
	
	public void setGreen(float value)
	{
		
		green = limitValue(value);
	}
	
	public void setBlue(float value)
	{
		
		blue = limitValue(value);
	}
	
	public void setAlpha(float value)
	{
		
		alpha = limitValue(value);
	}
	
	private float limitValue(float value)
	{
		if (value < 0.0f)
		{
			value = 0.0f;
		}
		if (value > 1.0f)
		{
			value = 1.0f;
		}
		return value;
	}
}
